<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <!--<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v5.0.1.min.js"></script>-->
    <script src="http://www.html5canvastutorials.com/lib/KineticJS/kinetic-v5.0.1-beta.js"></script>
    <script defer="defer">
    	
      var stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 500
      });
      var layer = new Kinetic.Layer();

      var hexagon = new Kinetic.RegularPolygon({
        x: stage.width()/2,
        y: stage.height()/2,
        sides: 6,
        radius: 70,
        fill: 'red',
        stroke: 'black',
        strokeWidth: 4
      });
      
      var hexagon2 = new Kinetic.RegularPolygon({
        x: stage.width()/2,
        y: stage.height()/2,
        sides: 10,
        radius: 50,
        fill: 'blue',
        stroke: 'grey',
        strokeWidth: 8
      });

      layer.add(hexagon);
      layer.add(hexagon2);
      stage.add(layer);

      var amplitude = 150;
      var period = 2000;
      // in ms
      var centerX = stage.width()/2;
      var centerY = stage.height()/2;

      var anim = new Kinetic.Animation(function(frame) {
        hexagon.setX(amplitude * Math.sin(frame.time * 2 * Math.PI / period) + centerX);
        hexagon2.setX(amplitude * Math.sin(frame.time * 3 * Math.PI / period) + centerX);
        hexagon2.setY(amplitude * Math.sin((Math.PI / 2) + frame.time * 3 * Math.PI / period) + centerY);
        
      }, layer);

      anim.start();

    </script>
  </body>
</html>